package com.examination.system.administration.response;

import com.examination.framework.model.response.ResultCode;
import com.google.common.collect.ImmutableMap;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

/**
 * @author 寇淇芮
 * @Dat 2019/8/17 23:52
 */
@ToString
public enum  AdministrationCode implements ResultCode {
    ADMINISTRATION_PARAMETER(false,10001,"掺数有问题"),
    COLLEGEMAJORCLASSIFICATIONEDIT(false,12001,"数据库没有该节点"),
    FAIL(false,12002,"操作失败"),
    SUCCESS(true,12003,"操作成功"),
    ERRNODE(false,12004,"数据节点异常"),
    COLLEGEMAJORCLASSIFICATIONADDNAME(false,12005,"添加的数据重复"),
    COLLEGEMAJORCLASSIFICATIONTOPPLATE(false,12006,"该数据不能删除");

    @ApiModelProperty(value = "操作是否成功", example = "true", required = true)
    private boolean success;
    @ApiModelProperty(value = "操作代码", example = "20001", required = true)
    private int code;
    @ApiModelProperty(value = "操作提示", example = "操作过于频繁！", required = true)
    private String message;

    private AdministrationCode(boolean success, int code, String message){
        this.success = success;
        this.code = code;
        this.message= message;
    }
    private static final ImmutableMap<Integer, AdministrationCode> CACHE ;
    static {
        final ImmutableMap.Builder<Integer, AdministrationCode> builder = ImmutableMap.builder();
        for (AdministrationCode commonCode : values()) {
            builder.put(commonCode.code(), commonCode);
        }
        CACHE = builder.build();
    }
    @Override
    public boolean success() {
        return success;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }
}
